﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;

namespace Entity
{
    public class LUONGKN
    {
        DataBaseAccess dataBaseAccess = new DataBaseAccess();

        private String MALUONGKN, MAGV;
        private int HOCKI, NAMHOC;
        private float TONGTIETHUONGDAN, TONGTIETNHANXET, TONGLUONGKN;

        public String maluongkn
        {
            get { return MALUONGKN; }
            set { MALUONGKN = value; }
        }

        public String magv
        {
            get { return MAGV; }
            set { MAGV = value; }
        }
        public int hocki
        {
            get { return HOCKI; }
            set { HOCKI = value; }
        }

        public int namhoc
        {
            get { return NAMHOC; }
            set { NAMHOC = value; }
        }
        public float tongtiethuongdan
        {
            get { return TONGTIETHUONGDAN; }
            set { TONGTIETHUONGDAN = value; }
        }
        public float tongtietnhanxet
        {
            get { return TONGTIETNHANXET; }
            set { TONGTIETNHANXET = value; }
        }

        public float luongkn
        {
            get { return TONGLUONGKN; }
            set { TONGLUONGKN = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dtgLuongCB"></param>
        /// 
        public void hienthi_LuongKN(DataGridView dtgLuongKN)
        {
            String excuteString = "SELECT * FROM BANGLUONGKN";
            DataTable dataTable = new DataTable();
            dataTable = dataBaseAccess.getDataTable(excuteString);
            dtgLuongKN.DataSource = dataTable;
        }

        public void xoa_LuongKN(String maluongKN)
        {
            String excuteString = "DELETE FROM BANGLUONGKN WHERE MALUONGKN='" + maluongKN + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void them_LuongKN(LUONGKN luongKN)
        {
            String excuteString = "INSERT INTO BANGLUONGKN VALUES('" + luongKN.maluongkn + "','"
                                                                 + luongKN.magv + "',"
                                                                 + luongKN.hocki + ","
                                                                 + luongKN.namhoc + ","
                                                                 + luongKN.tongtiethuongdan + ","
                                                                 + luongKN.tongtietnhanxet + ","
                                                                 + luongKN.luongkn + ")";


            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void sua_LuongKN(LUONGKN luongKN)
        {
            String excuteString = "UPDATE BANGLUONGKN SET MAGV='" + luongKN.magv +
                                                  "',HOCKI =" + luongKN.hocki +
                                                  ",NAMHOC =" + luongKN.namhoc +
                                                  ",TONGTIETHD =" + luongKN.tongtiethuongdan +
                                                  ",TONGTIETHD =" + luongKN.tongtietnhanxet +
                                                  ",LUONGKN =" + luongKN.luongkn +
                                                  " WHERE MALUONGKN='" + luongKN.maluongkn + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }
    }
}
